﻿using System.Security.Cryptography;

namespace MedicalSoft.Application.HIS.Util.CryptoUtil.Hash
{
    /// <summary>
    /// Hmacsha1Util 工具
    /// </summary>
    public class Hmacsha1Util
    {
        /// <summary>
        /// 前面
        /// </summary>
        /// <param name="plainTxt"></param>
        /// <param name="secret"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static string Encrypt(string plainTxt,string secret, Encoding encoding)
        {
            HMACSHA1 hmacsha1 = new HMACSHA1();

            hmacsha1.Key = encoding.GetBytes(secret);

            byte[] dataBuffer = encoding.GetBytes(plainTxt);

            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);

            return Convert.ToBase64String(hashBytes);
        }
    }
}
